#include "render_card.h"

render_card::render_card(enum PlayerID p, int index) :
    Widget(),
    cardimage(NULL),
    cardimage_s(NULL),
    backimage(NULL),
    player(p),
    handindex(index),
    cardid(0),
    show_cardback(true)
{
}

render_card::~render_card(void)
{
}

void render_card::set_cardid(int id)
{
    cardid = id;
}

void render_card::set_backimage(SDL_Surface *image)
{
    backimage = image;
    if (show_cardback) {
        p_surface = backimage;
    } else {
        p_surface = cardimage_s;
    }
}

void render_card::set_cardimage(SDL_Surface *image)
{
    cardimage = image;
    if (show_cardback) {
        p_surface = backimage;
    } else {
        p_surface = cardimage_s;
    }
}

void render_card::set_cardimage_s(SDL_Surface *image)
{
    cardimage_s = image;
    if (show_cardback) {
        p_surface = backimage;
    } else {
        p_surface = cardimage_s;
    }
}

void render_card::set_show_cardback(bool b)
{
    show_cardback = b;
}

SDL_Surface * render_card::get_cardimage()
{
    return cardimage;
}

void render_card::draw(SDL_Surface *screen)
{
    Widget::draw(screen);
}

void render_card::update()
{
    if (show_cardback) {
        p_surface = backimage;
    } else {
        p_surface = cardimage_s;
    }
    Widget::update();
}
